package cm367;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;

@ManagedBean
@ApplicationScoped
public class VenueService {
	private List<Venue> venuelist = new ArrayList<Venue>();
	private HashMap<String, Venue> venuemap = new HashMap<String, Venue>();
	private Date date;
	private byte period;
	private Calendar calendar;

	public VenueService() {
		DataConnection d = new DataConnection();
		List<String> tmp = d.getTable("db_venue.txt");
		
		Venue v = null;
		for (int i = 1; i < tmp.size(); i++) {
			v = new Venue(tmp.get(i));
			venuemap.put(v.getCode(), v);
			venuelist.add(v);
		}
	}
	
	public Venue findVenuebyCode(String venuecode){
		return (Venue)venuemap.get(venuecode);
	}

	public List<Venue> getVenuelist() {
		return venuelist;
	}

	public HashMap<String, Venue> getVenuemap() {
		return venuemap;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
		calendar = Calendar.getInstance();
		calendar.setTime(date);
	}

	public byte getPeriod() {
		return period;
	}

	public void setPeriod(byte period) {
		this.period = period;
	}

	public Calendar getCalendar() {		
		return calendar;
	}

	public void setCalendar(Calendar calendar) {
		this.calendar = calendar;
	}	
}
